package com.mondo.financialwallet.presentation.ui.adapter;

import android.content.res.Resources;
import android.graphics.Color;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mondo.financialwallet.R;
import com.mondo.financialwallet.presentation.model.FinancialOrderList;

// TODO 中文
public class FinancialOrderListAdapter extends BaseQuickAdapter<FinancialOrderList, BaseViewHolder> {

    public static FinancialOrderListAdapter create() {

        return new FinancialOrderListAdapter(
                R.layout.item_financial_order_list
        );
    }

    public FinancialOrderListAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, FinancialOrderList item) {
        Resources resources = helper.itemView.getContext().getResources();

        helper.setText(R.id.type_text_view, item.getType() == 6 ? "清算" : "买入");
        helper.setText(R.id.amount_text_view, item.getAmount());
        helper.setText(R.id.name_text_view, item.getName());
        helper.setText(R.id.date_text_view, item.getDate());
        helper.setTextColor(R.id.amount_text_view, item.getType() == 6
                ? resources.getColor(R.color.colorPrimary)
                : Color.parseColor("#FF9600"));
    }
}
